#pragma once
#include "audionode.h"
#include <cmath>
#include <vector>

class CAdditiveSynth :
	public CAudioNode
{
public:
	CAdditiveSynth(void);
	~CAdditiveSynth(void);

public:
    virtual void Start();
    virtual bool Generate();

    void SetFreq(double f) {m_freq = f;}
    void SetAmplitude(int i, double a) {m_amp.push_back(a);}
	void SetAmplitudeFade(int i, double a) {m_ampfade.push_back(a);}
	void SetDuration(double d) {m_duration = d;}
	void SetVibrato(bool v, double vf, double m) {m_vibrato = v; m_vibratofreq = vf; m_modulation = m;}

private:
    double m_freq;
    double m_phase;
    std::vector<double> m_amp;
	std::vector<double> m_ampfade;
	double GenerateCrossfade(void);
	double m_time;
	double m_duration;
	bool m_vibrato;
	double m_vibratofreq;
	double m_modulation;
	double m_vibratophase;
};

